From : C.Dimitrakakis (MBGE4CD1@fs1.ee.man.ac.uk)
Subject : Reducing colors of a shape
> #2 could't anyone write a library for
> remapping e.g. 6 plane shape to an 2 plane - one... ???
Here is a small algorithm for converting
a m-plane shape to a n-plane shape
with predetermined colours, that uses dithering
*The shape has dimensions Wx,Wy.
*original shape is number 1
*decreased shape is number 2
--Get the colour at one pixel.
--Search the palette for the two closest colours
The best way to do that is to calculate an error% for
each available colour and use the smallest ones IMHO.
Another way, that is best with dithering, is to get
the smallest 2 values that have a different error sign.(difficult to
do fast)
*Random Dithering
--Choose the appropriate color by using a uniform distribution
such as Rnd. The possibility of a color been chosen should be equal
to the ratio of error between that color and the other.
*Normal dithering
--Instead of using a random function, you can use that possibility
in order to determine an appropriate dither pattern. That complicates
things a bit, as you will have to have use x and y to determine
which pixel in the pattern should be displayed.
--Go back until no more pixels
There is also a technique that increases the picture contrast in order
to get better-looking results. This is done by mapping the lower and
higher intensity colours of the original shape to the corresponding
colours of the predetermined palette.
--
If you look into the subject's literature, you will find hundreds of
methods to do that. Take your pick. I can give you some references if
you want.